package com.engine4cloud.tdf.supervision.controller.inner;

import com.engine4cloud.tdf.common.core.util.R;
import com.engine4cloud.tdf.common.log.annotation.SysLog;
import com.engine4cloud.tdf.common.security.annotation.Inner;
import com.engine4cloud.tdf.supervision.dto.create.TerminalRegistrationCreateDTO;
import com.engine4cloud.tdf.supervision.dto.result.TerminalRegistrationResultDTO;
import com.engine4cloud.tdf.supervision.dto.update.TerminalRegistrationUpdateDTO;
import com.engine4cloud.tdf.supervision.service.JzdxTerminalService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;

/**
 * 报道登记
 *
 * @author wenjie
 * @date 2024-03-14 11:20:26
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/inner/corrector")
@Tag(description = "CorrectorTerminal", name = "矫正对象-报道登记-inner")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class JzdxRegistrationInnerController implements Serializable {
    @Resource
    private JzdxTerminalService terminalService;

    /**
     * 通过身份证号查询注册人员详情
     *
     * @param identity 身份证号
     * @return R
     */
    @Inner
    @Operation(summary = "通过身份证号查询注册人员详情", description = "通过身份证号查询注册人员详情")
    @GetMapping("/{identity}")
    public R<TerminalRegistrationResultDTO> getByIdentity(@Schema(description = "矫正对象身份证号") @PathVariable("identity") String identity) {
        return R.ok(terminalService.getByIdentity(identity));
    }

    /**
     * 矫正对象报到登记-注册
     *
     * @param dto 矫正对象报到登记-注册
     * @return R
     */
    @Inner
    @Operation(summary = "矫正对象报到登记-注册", description = "矫正对象报到登记-注册")
    @SysLog("矫正对象报到登记注册")
    @PostMapping
    public R<String> register(@Valid @RequestBody TerminalRegistrationCreateDTO dto) {
        return R.ok(terminalService.register(dto));
    }

    /**
     * 矫正对象报到登记-注册
     *
     * @param dto 矫正对象报到登记-注册
     * @return R
     */
    @Inner
    @Operation(summary = "矫正对象报到登记-更新", description = "矫正对象报到登记-更新")
    @SysLog("矫正对象报到登记-更新")
    @PutMapping
    public R<Boolean> update(@Valid @RequestBody TerminalRegistrationUpdateDTO dto) {
        return R.ok(terminalService.update(dto));
    }

}
